<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
</head>
<body>
<form action="calculater.jsp" method="post">
    <table border="1px" >
        <tr>
            <th colspan="2"><h1>简易计算器</h1></th>
        </tr>
        <tr>
            <td>第1个数：</td>
            <td><input type="text" name="firstnum"
                       value="<%=request.getParameter("firstnum")==null?"":request.getParameter("firstnum")%>" /></td> <!-- 用于提交后保存数据value="<%=request.getParameter("firstnum")%>"  -->
        </tr>
        <tr>
            <td>第2个数：</td>
            <td><input type="text" name="secondnum"
                       value="<%=request.getParameter("secondnum")==null?"":request.getParameter("secondnum")%>" /></td>
        </tr>
        <tr>
            <td>操作类型：</td>
            <td><select name="oper">
                <option value="+">+
                <option value="-">-
                <option value="*">*
                <option value="/">/
            </select>
                <input type="submit" value="计算"></td>
        </tr>
        <tr>
            <td>计算结果：</td>
            <td>
                <jsp:useBean id="result" class="cal.Calculater"></jsp:useBean>
                <jsp:setProperty property="firstnum" name="result" param="firstnum"/>
                <jsp:setProperty property="secondnum" name="result" param="secondnum"/>
                <jsp:setProperty property="oper" name="result" param="oper"/>
                <%if(result.getOper()==null){
                }
                else{%>
                <%=result.getFirstnum()%><%=result.getOper() %><%=result.getSecondnum() %>=<%=result.getResult() %>
                <%} %>

            </td>
        </tr>
    </table>
</form>
</body>
</html>
